import { CrossDefenceCopyMenuBase } from "./CrossDefenceCopyMenuBase";
import { CrossDefenceBuildMenuItemTips } from "./item/CrossDefenceBuildMenuItemTips";
import { CrossDefenceCanBuildData } from "./data/CrossDefenceCanBuildData";
import { CrossDefenceBuildMenuItem } from "./item/CrossDefenceBuildMenuItem";
//class CrossDefenceCopyBuildMenu
    
    export  class CrossDefenceCopyBuildMenu extends CrossDefenceCopyMenuBase
    {
        constructor(arg1: Array<any>, arg2: Boolean=false, arg3: string="", arg4: string="")
        {
            super(_buildingImgs, "CrossTowerTowerTitle.png", "CrossTowerTowerIcon.png", CrossDefenceBuildMenuItemTips, arg2, arg3, arg4);
            _buildingImgs = arg1;
            _skillMaxNum = _buildingImgs.length;
            return;
        }

        public updateBuildable(arg1: Array<any>): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=0;
            while (loc1 < arg1.length && loc1 < _items.length) 
            {
                loc2 = arg1[loc1] as CrossDefenceCanBuildData;
                if (loc2 != null) 
                {
                    (loc3 = _items[loc1] as CrossDefenceBuildMenuItem).enabled = loc2.canBuild;
                    loc3.canBuildNum = loc2.canBuildNum;
                }
                ++loc1;
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=null;
            var loc3=null;
            super.createChildren();
            _items = [];
            var loc2=0;
            while (loc2 < _buildingImgs.length) 
            {
                loc3 = _buildingImgs[loc2];
                loc1 = new CrossDefenceBuildMenuItem(loc3, 5);
                loc1.x = loc2 * _skillSlotWidth;
                loc1.y = 0;
                loc1.addEventListener(flash.events.Event.ADDED_TO_STAGE, onAddToStage);
                _container.addChild(loc1);
                _items.push(loc1);
                ++loc2;
            }
            return;
        }
    }
